<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>goods</title>
    <script src="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
</head>
<script type="text/javascript">
    function pay(orderId) {
        $.get("http://127.0.0.1:8080/shopping/pay?orderId="+orderId, function () {
            window.location.href = "http://127.0.0.1:8080/shopping/list";
        });
    }
</script>
<body>
<div style="margin-left: 40%; margin-top: 10%">
    <table border="1">
        <caption>orders</caption>
        <tr>
            <th>id</th>
            <th>status</th>
            <th>pay</th>
        </tr>
        <tr th:each="order:${orders}">
            <form>
                <td th:text="${order.id}"></td>
                <td th:text="${order.status}"></td>
                <td th:if="${order.status == '待支付'}"><input type="button" value="buy" th:onclick="pay([[${order.id}]]);"></td>
            </form>

        </tr>
    </table>
</div>
</body>
</html>